<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      height: 100%;
    }

    main {
      width: 50%;
      height: 400px;
      margin: auto;
      margin-top: 150px;


    }

    .box {
      width: 150px;
      height: 80px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid #000;
      transform-origin: top right;
      transition: transform 2s ease;
      position: relative;
      overflow: hidden;
      transition: color .7s ease;
      margin-bottom: 50px;


    }

    .box::before {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background-color: aquamarine;
      z-index: -1;
      transition: transform .7s ease-in-out;
    }

    .box:hover {
      color: red;
    }

    .box0::before {
      transform: translate(-100%, 0);
    }
    .box0:hover::before{
      transform: translate(0,0);
    }

    .box1::before{
      transform: translate(100%,0);
    }
    .box1:hover::before{
      transform: translate(0,0);
    }


    .box2::before {
      transform: translate(0, -100%);
    }
    .box2:hover::before {
      transform: translate(0, 0)
    }

    .box3::before{
      transform: translate(0,100%);
    }
    .box3:hover::before{
      transform: translate(0,0)
    }
  </style>
</head>

<body>
  <main>
    <div class="box box0">button</div>
    <div class="box box1">button</div>
    <div class="box box2">button</div>
    <div class="box box3">button</div>
  </main>
</body>

</html>